package com.future;

import com.future.util.TreeNode;

/**
 * Description: 104. 二叉树的最大深度
 *
 * @author weiruibai.vendor
 * Date: 2022/7/23 21:25
 */
public class Solution_104 {

    public static void main(String[] args) {

    }

    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        }
        return process(root);
    }

    private int process(TreeNode root) {
        if (root == null) {
            return 0;
        }
        // 左边
        int leftHeight = process(root.left);
        int rightHeight = process(root.right);
        return 1 + Math.max(leftHeight, rightHeight);
    }
}
